package middle;

import util.PrintUtils;

public class Solution_260 {

    public static void main(String[] args) {
        Solution_260 model = new Solution_260();
        PrintUtils.arrayInt(model.singleNumber(new int[]{744132272, -145417756}));
//        PrintUtils.arrayInt(model.singleNumber(new int[]{1, 2, 1, 3, 2, 5}));
//        PrintUtils.arrayInt(model.singleNumber(new int[]{-1, 0}));
//        PrintUtils.arrayInt(model.singleNumber(new int[]{0, 1}));
//        PrintUtils.arrayInt(model.singleNumber(new int[]{43772400,1674008457,1779561093,744132272,1674008457,448610617,1779561093,124075538,-1034600064,49040018,612881857,390719949,-359290212,-812493625,124732,-1361696369,49040018,-145417756,-812493625,2078552599,1568689850,865876872,865876872,-1471385435,1816352571,1793963758,2078552599,-1034600064,1475115274,-119634980,124732,661111294,-1813882010,1568689850,448610617,1347212898,-1293494866,612881857,661111294,-1361696369,1816352571,-1813882010,-359290212,1475115274,1793963758,1347212898,43772400,-1471385435,124075538,-1293494866,-119634980,390719949}));
    }

    public int[] singleNumber(int[] nums) {
        long num = 0;
        for (int n : nums) {
            num ^= n;
        }
        if (num == 0) {
            return null;
        }
        num = num - (num & (num - 1));
//        int count = 0;
//        while (num != 0) {
//            if ((num & 1) == 1) {
//                break;
//            }
//            num >>= 1;
//            count++;
//        }
//        num = 1L << count;
        long a = 0, b = 0;
        for (int n : nums) {
            if ((n & num) != 0) {
                a ^= n;
            } else {
                b ^= n;
            }
        }
        return new int[]{(int)a, (int)b};
    }
}
